package org.example.ch02.p09;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList<String>List=new ArrayList<>();
        while(scanner.hasNext()){
            String token=scanner.next();
            if (token.equals("end")){
                break;
            }
            if(token.length()%3==0){
                List.add(token);
            }
        }
        StringBuilder result=new StringBuilder();
        for (String str : List){
            result.append(str).append(" ");
        }
        System.out.println(result.toString());
        scanner.close();
    }
}
